package creatorMode.singletonPattern.lazy;

import creatorMode.singletonPattern.hungry.Singleton1;

//线程安全的懒汉式--利用synchronized对方法
//加锁性能低
public class Singleton2 {
private static Singleton2 singleton2;
private Singleton2 (){

}
public static synchronized Singleton2 getInstance(){
    if(singleton2==null)singleton2=new Singleton2();
    return singleton2;
}

}
